package cn.stylefeng.guns.modular.clb.controller;

import cn.stylefeng.guns.modular.clb.pojo.request.ClbRequest;
import cn.stylefeng.guns.modular.clb.service.ClbService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 车辆表控制器
 *
 * @author zhu
 * @date 2021/10/06 11:12
 */
@RestController
@ApiResource(name = "车辆表")
public class ClbController {

    @Resource
    private ClbService clbService;

    /**
     * 添加
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @PostResource(name = "添加", path = "/clb/add")
    public ResponseData add(@RequestBody @Validated(ClbRequest.add.class) ClbRequest clbRequest) {
        clbService.add(clbRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @PostResource(name = "删除", path = "/clb/delete")
    public ResponseData delete(@RequestBody @Validated(ClbRequest.delete.class) ClbRequest clbRequest) {
        clbService.del(clbRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @PostResource(name = "编辑", path = "/clb/edit")
    public ResponseData edit(@RequestBody @Validated(ClbRequest.edit.class) ClbRequest clbRequest) {
        clbService.edit(clbRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @GetResource(name = "查看详情", path = "/clb/detail")
    public ResponseData detail(@Validated(ClbRequest.detail.class) ClbRequest clbRequest) {
        return new SuccessResponseData(clbService.detail(clbRequest));
    }

    /**
     * 获取列表
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @GetResource(name = "获取列表", path = "/clb/list")
    public ResponseData list(ClbRequest clbRequest) {
        return new SuccessResponseData(clbService.findList(clbRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhu
     * @date 2021/10/06 11:12
     */
    @GetResource(name = "分页查询", path = "/clb/page")
    public ResponseData page(ClbRequest clbRequest) {
        return new SuccessResponseData(clbService.findPage(clbRequest));
    }

}